<?php
namespace app\index\model;

use think\Model;

class Item extends Model{

    private $itemModel;
    public function __construct(){
        parent::__construct();
        $this -> itemModel = db('item');
    }

    /*  获取项目数据
     *  @param Array [where]
     *  @return Array [dataList]
     * **/
    public function getItemDataList($where,$order = false ,$type = 1,$limit = false , &$redun = false ){
        $data = $this -> itemModel -> where($where) -> order($order) -> limit($limit) -> select();
        if(empty($data)){   return [];  }
        switch ($type) {
            case 1:
                $dataList = $this -> formatItemDataForIdTitle($data);
                break;

            default:
                # code...
                break;
        }
        return $dataList;
    }
    /*  获取项目数据
     *  @param Array [data]
     *  @return Array [list]
     * **/
    public function formatItemDataForIdTitle($data){
        foreach ($data as $key => $value) {
            $list[$key]['id'] = $value['id'];
            $list[$key]['title'] = $value['title'];
            $list[$key]['url'] = $value['url'];
        }
        return $list;
    }


}